Skip to content

Use pointermove instead of mousemove to allow touch interactions to work #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 16, 2024

Conversation

nedredmond
Copy link
Contributor

Just swaps out mousemove in favor of pointermove, which encapsulates mouse, touch, and pen events. Since PointerEvent inherits from MouseEvent, there is no other change needed for this to work. See the MDN page for PointerEvent.

The other bound event, click, already handles touch events, so nothing else is needed to make this plugin compatible with touch events.

Should fix #66 (as far as touchmove -- the other two are fixed by using pointer events to cover all interactions)

@Fuzzyma
Copy link
Member

Fuzzyma commented Nov 16, 2024

@nedredmond are there any mouse events you didnt cover?
Asking because if this:

the other two are fixed by using pointer events to cover all interactions

@nedredmond
Copy link
Contributor Author

nedredmond commented Nov 16, 2024

@nedredmond are there any mouse events you didnt cover?
Asking because if this:

the other two are fixed by using pointer events to cover all interactions

I meant those two "other two" (touchstart and touchend) are handled by the consumer, and it works if they use pointer events instead, as in drawArea.pointerdown((e) => drawing.draw()) and drawArea.pointerup((e) => drawing.draw("stop")) (not sure I'm getting the syntax right, on my phone -- but you get it) which cover mouse, touch, and stylus events.

I think the user that reported the issue was seeing that the draw between touch start and touch end didn't work. With pointermove, it will.

@Fuzzyma
Copy link
Member

Fuzzyma commented Nov 16, 2024

Ah OK. I see. Thanks :)

@Fuzzyma Fuzzyma merged commit 03204a1 into svgdotjs:master Nov 16, 2024
@nedredmond
Copy link
Contributor Author

nedredmond commented Nov 17, 2024

@Fuzzyma, thanks for accepting my PR!

When might this be published? I'm using this for a bugfix at work (just migrated us from raphael) and I'd like to replace import to a git url to my own fork as soon as I can.

No rush for you of course, but would you let me know when the node package is published?

@Fuzzyma
Copy link
Member

Fuzzyma commented Nov 17, 2024

@nedredmond I merged from my phone so I couldnt publish right away :D. It should be available now.
Nice to hear that people still use this lib and even moving from something like raphael!

May I ask what you are building?

@nedredmond
Copy link
Contributor Author

I refactored the drawing tools on Khan Academy exercises so that we can improve / extend them for accessibility. They let learners draw on the margins of their exercises while they work.

After the migration, it's broken for touch experiences. Whoops! Thanks for helping me get this fix in so quickly.

@Fuzzyma
Copy link
Member

Fuzzyma commented Nov 17, 2024

Uh interesting. Hope svg.js will serve you well :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to deal with touchstart - touchmove - touchend ?
2 participants